#!/bin/bash
set -e
if [ -z "${MountPoint}" ]; then
    EnvFile="../common/0_env.sh"
    # shellcheck source=../common/0_env.sh
    source ${EnvFile}
fi

echo -e "\n***********************************************************************"
echo -e "\t\t$0 : 测试包含硬链接文件时 orcafs-ctl --du 与 系统 du 是否一致"
echo -e "***********************************************************************"

dirName="/test_du_hardlink"
absDirPath="${MountPoint}${dirName}"
mkdir -p "${absDirPath}"
orcafs-ctl --setpattern --storagepoolid=2 "${absDirPath}" &> /dev/null

dd if=/dev/zero of="${absDirPath}/file" bs=1000 count=1
sleep 1

sysDuSize=`du -sb "${absDirPath}" | awk '{print $1}'`
test_du_size_all "${dirName}" "${sysDuSize}"

# 创建硬链接文件
ln "${absDirPath}/file" "${absDirPath}/file.hardlink"

sysDuSize=`du -sb "${absDirPath}" | awk '{print $1}'`
test_du_size_all ${dirName} "${sysDuSize}"

rm_abs_dir "${absDirPath}"

